home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 683 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: gets() question
  5. Date: 08 Jan 1996 15:41:26 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Jan8084126@qcd.lanl.gov>
  8. References: <4cosgf$rir@newsbf02.news.aol.com> <4cqkt8$1quo@news.gate.net>
  9.     <821109116snz@genesis.demon.co.uk>
  10. NNTP-Posting-Host: qcd.lanl.gov
  11. Mime-Version: 1.0
  12. Content-Type: text
  13. In-reply-to: Lawrence Kirby's message of Mon, 08 Jan 96 13:51:56 GMT
  14.  
  15. --text follows this line--
  16. In article <821109116snz@genesis.demon.co.uk> Lawrence Kirby
  17. <fred@genesis.demon.co.uk> writes: 
  18. <snip>
  19.    It is certainly better to use fgets rather than gets but you could have
  20.    written:
  21.  
  22.         fgets(s[0],sizeof s[0],stdin);
  23.  
  24.    s[0] is equivalent to &s[0][0] in this context and is arguably more
  25.    readable. The length argument of fgets specifies the size of the array
  26.  
  27. Just to point out the obvious, the first s[0] is equivalent to
  28. &s[0][0]. The s[0] in sizeof s[0] is not!
  29.  
  30. (argument of sizeof and argument of & are two conditions unders which
  31. s[0] will not `decay' into &s[0][0].)
  32.  
  33. Cheers
  34. Tanmoy
  35. --
  36. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  37. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  38. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  39. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  40. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  41. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  42.